let request = (url, method, params) => {
  return new Promise((resolve, reject) => {
    var mytoken = wx.getStorageSync("token")
    wx.request({
      url: "http://localhost:3000" + url,
      method,
      header: {
        'content-type': 'application/json',
        "token": `${mytoken}`
      },
      data: {
        ...params
      },
      success: (res) => {
        if (res.data.code === 200) {
          const token = res?.data?.data?.token
          token && wx.setStorageSync('token', token)
          const customerId = res?.data?.data?.customerId
          customerId && wx.setStorageSync('id', customerId)
          resolve(res)
        } else {
          if (res.data.code === 403) {
            wx.removeStorageSync('token');

          }
          wx.showToast({
            title: res.data.msg,
            icon: 'none'
          })
          resolve(res)
        }
      },
    })
  })
}
export default request